let arr1 = [
  {
    name: "张三",
    money: 100,
    children: [
      { name: "张欢欢", money: 200 },
      {
        name: "张乐乐",
        money: 100,
        children: [
          { name: "张小欢", money: 300 },
          { name: "张小乐", money: 400 },
        ],
      },
    ],
  },
  {
    name: "李四",
    money: 100,
    children: [
      { name: "李红红", money: 500 },
      { name: "李明明", money: 600 },
    ],
  },
];

let total = 0;
function getTotal(arr, total) {
  arr.forEach((item) => {
    if (item.children) {
      return getTotal(item.children, total);
    } else {
      return (total += item.money);
    }
  });
}

let result = getTotal(arr1, total);
console.log(result);
console.log(total,"111")
// console.log(total)
